﻿

<!-- Bootstrap 5 JS Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

<script>
	// 关注按钮功能
	document.querySelectorAll('.follow-btn').forEach(btn => {
		btn.addEventListener('click', function () {
			if (this.classList.contains('following')) {
				this.classList.remove('following');
				this.innerHTML = '<i class="fas fa-plus me-1"></i> 关注';
			} else {
				this.classList.add('following');
				this.innerHTML = '<i class="fas fa-check me-1"></i> 已关注';
			}
		});
	});

	// 点赞功能
	document.querySelectorAll('.like-btn').forEach(btn => {
		btn.addEventListener('click', function () {
			const icon = this.querySelector('i');
			const countSpan = this.querySelector('span');
			let count = parseInt(countSpan.textContent);

			if (icon.classList.contains('far')) {
				icon.classList.remove('far');
				icon.classList.add('fas');
				this.classList.add('liked');
				countSpan.textContent = (count + 1) + ' 点赞';
			} else {
				icon.classList.remove('fas');
				icon.classList.add('far');
				this.classList.remove('liked');
				countSpan.textContent = (count - 1) + ' 点赞';
			}
		});
	});

	// 收藏功能
	document.querySelectorAll('.bookmark-btn').forEach(btn => {
		btn.addEventListener('click', function () {
			const icon = this.querySelector('i');

			if (icon.classList.contains('far')) {
				icon.classList.remove('far');
				icon.classList.add('fas');
				this.classList.add('saved');
				this.querySelector('span').textContent = '已收藏';
			} else {
				icon.classList.remove('fas');
				icon.classList.add('far');
				this.classList.remove('saved');
				this.querySelector('span').textContent = '收藏';
			}
		});
	});

	// 分享功能
	document.querySelectorAll('.share-btn').forEach(btn => {
		btn.addEventListener('click', function () {
			alert('分享选项：复制链接、微信好友、朋友圈、微博等');
		});
	});

	// 评论点赞功能
	document.querySelectorAll('.like-action').forEach(action => {
		action.addEventListener('click', function () {
			const icon = this.querySelector('i');
			const countSpan = this.querySelector('span');
			let count = parseInt(countSpan.textContent);

			if (icon.classList.contains('far')) {
				icon.classList.remove('far');
				icon.classList.add('fas');
				this.classList.add('liked');
				countSpan.textContent = count + 1;
			} else {
				icon.classList.remove('fas');
				icon.classList.add('far');
				this.classList.remove('liked');
				countSpan.textContent = count - 1;
			}
		});
	});

	// 回复功能
	document.querySelectorAll('.reply-action').forEach(action => {
		action.addEventListener('click', function () {
			// 找到最近的回复输入框并聚焦
			const replyInput = this.closest('.comment-item, .reply-item').querySelector('.reply-textarea');
			if (replyInput) {
				replyInput.focus();
			}
		});
	});

	// 评论提交功能
	document.querySelector('.submit-btn').addEventListener('click', function () {
		const textarea = this.closest('.comment-input-container').querySelector('.comment-textarea');
		if (textarea.value.trim() === '') {
			alert('请输入评论内容');
			return;
		}

		alert('评论发布成功！');
		textarea.value = '';
	});

	// 取消评论功能
	document.querySelectorAll('.cancel-btn').forEach(btn => {
		btn.addEventListener('click', function () {
			const textarea = this.closest('.comment-input-container, .reply-input-container').querySelector('textarea');
			textarea.value = '';
		});
	});

	// 加载更多评论
	document.querySelector('.btn-outline-primary').addEventListener('click', function () {
		this.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i>加载中...';

		// 模拟加载延迟
		setTimeout(() => {
			this.innerHTML = '<i class="fas fa-comments me-2"></i>查看更多评论';
			alert('已加载全部评论');
		}, 1500);
	});
</script>

